package com.itcast.arrays;

import com.itcast.Array.Student;

import java.util.Arrays;
import java.util.Comparator;

/*
    如果降序排序
 */
public class Test7 {

    public static void main(String[] args) {
        Student[] arr = {new Student("aaa", 18, 170, 65, 100), new Student("bbb", 17, 179, 70, 10), new Student("ccc", 15, 177, 55, 20), new Student("ddd", 19, 176, 50, 15), new Student("eee", 16, 180, 52, 90),};

        Arrays.sort(arr, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o2.getAge() - o1.getAge();
            }
        });
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
